/**
 * @author Evgeny Sorokin
 */
Ext.define('USocial.controller.PostMessage',{
	extend : 'Ext.app.Controller',
	
	config : {
		refs : {
			postMessageField : '#postMessageField'
		},
		control : {
			postMessageField : {
				focus :  function(field, e, eOpts, extEvent){
					Ext.Viewport.add(Ext.create('USocial.view.PostMessageModal'));
				}
			}
		}
	},

	init : function(){
		
		USocial.app.on('approach', function(appUser, friend){
			var message = 'Would you like to post message about meeting with '+friend.get('first_name')+' '+friend.get('last_name');
			if(Ext.device){
				Ext.device.Notification.show({
					title : message,
					buttons : Ext.MessageBox.OKCANCEL,
					callback : function(button){
						if(button === 'ok'){
							Ext.Viewport.add(Ext.create('USocial.view.PostMessageModal'));
						}
					}
				});
			}else{
				if(confirm(message)){
					Ext.Viewport.add(Ext.create('USocial.view.PostMessageModal'));
				}
			}
			friend.set('checked', true);
		});
	}
	
});